﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DC2010;
using DC2010.Objects;

namespace DC2010_EditorData.Dialogs
{
    public partial class DungeonLocForm : Form
    {
        public DungeonLoc DungeonLoc { get; set; }

        public DungeonLocForm()
        {
            InitializeComponent();
        }

        public DungeonLocForm(DungeonLoc loc) : this()
        {
            DungeonLoc = loc;
        }

        private void DungeonLocForm_Load(object sender, EventArgs e)
        {
            textBox1.Text = DungeonLoc.X.ToString();
            textBox2.Text = DungeonLoc.Y.ToString();

            comboBox1.Items.Clear();
            foreach (var value in Root.I.FloorSystem.DictInfo.Values)
            {
                comboBox1.Items.Add(value.Id);
            }

            comboBox1.Text = DungeonLoc.FloorId;

            switch (DungeonLoc.Facing)
            {
                case Directions.North:
                    radioButton1.Checked = true;
                    break;
                case Directions.East:
                    radioButton2.Checked = true;
                    break;
                case Directions.South:
                    radioButton4.Checked = true;
                    break;
                case Directions.West:
                    radioButton3.Checked = true;
                    break;
            }

        }

        private void DungeonLocForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            DungeonLoc.X = textBox1.Text.ToInt();
            DungeonLoc.Y = textBox2.Text.ToInt();
            DungeonLoc.FloorId = comboBox1.Text;

            if (radioButton1.Checked) DungeonLoc.Facing = Directions.North;
            if (radioButton2.Checked) DungeonLoc.Facing = Directions.East;
            if (radioButton4.Checked) DungeonLoc.Facing = Directions.South;
            if (radioButton3.Checked) DungeonLoc.Facing = Directions.West;

            Close();
        }

    }
}
